package cj.web.kly.dao;
/*
 *  
 *  
*/
import java.util.List;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.kly.domain.GroupPeople;

/**
 * 
 * @author 
 *
 */
@DAO
public interface GroupPeopleDAO{
	
	@SQL("SELECT * FROM GroupPeople WHERE depId is null AND groupId is null AND deleteFlag=1 #if(:t.name != null){ AND name LIKE '%##(:t.name)%' } ORDER BY updateAt DESC LIMIT :t.start,:t.length ")
    List<GroupPeople> queryNoExist(@SQLParam("t") GroupPeople groupPeople);
		
	@SQL("SELECT count(1) FROM GroupPeople WHERE depId is null AND groupId is null AND deleteFlag=1 #if(:t.name != null){ AND name LIKE '%##(:t.name)%' }" )
    int queryNoExistSize(@SQLParam("t") GroupPeople groupPeople);
	
	@SQL("SELECT * FROM GroupPeople WHERE id=:1 ")
    GroupPeople queryNoExistById(int id);
	
	@SQL("SELECT a.*,b.name as depName,c.name as groupName FROM GroupPeople a join GroupDep b on a.depId=b.id join GroupInfor c on a.groupId=c.id WHERE a.deleteFlag=1 AND a.depId=:t.depId #if(:t.name != null){ AND a.name LIKE '%##(:t.name)%' } ORDER BY a.updateAt DESC LIMIT :t.start,:t.length ")
    List<GroupPeople> query(@SQLParam("t") GroupPeople groupPeople);
		
	@SQL("SELECT count(1) FROM GroupPeople WHERE deleteFlag=1 AND depId=:t.depId #if(:t.name != null){ AND name LIKE '%##(:t.name)%' }" )
    int querySize(@SQLParam("t") GroupPeople groupPeople);
    
    @SQL("SELECT a.*,b.name as depName,c.name as groupName FROM GroupPeople a join GroupDep b on a.depId=b.id join GroupInfor c on a.groupId=c.id WHERE a.id=:1 ")
    GroupPeople queryById(int id);
    
    @SQL("INSERT INTO GroupPeople (groupId,labelId,depId,type,depOrderNo,name,descs,photo,honor,jobTitle,political,birthdate,address,tel,email,education,major,school,direction,subject,achievements,infor,orderNo,deleteFlag,createUser,createAt,updateUser,updateAt) VALUES (:t.groupId,:t.labelId,:t.depId,:t.type,:t.depOrderNo,:t.name,:t.descs,:t.photo,:t.honor,:t.jobTitle,:t.political,:t.birthdate,:t.address,:t.tel,:t.email,:t.education,:t.major,:t.school,:t.direction,:t.subject,:t.achievements,:t.infor,:t.orderNo,1,:t.createUser,now(),:t.updateUser,now())")
    void create(@SQLParam("t") GroupPeople groupPeople);
	
	@SQL("UPDATE GroupPeople SET "
	    			        + "groupId=:t.groupId,"
	    			        + "labelId=:t.labelId,"
	    			        + "depId=:t.depId,"
	    			        + "type=:t.type,"
	    			        + "depOrderNo=:t.depOrderNo,"
	    			        + "name=:t.name,"
	    			        + "descs=:t.descs,"
	    			        + "photo=:t.photo,"
	    			        + "honor=:t.honor,"
	    			        + "jobTitle=:t.jobTitle,"
	    			        + "political=:t.political,"
	    			        + "birthdate=:t.birthdate,"
	    			        + "address=:t.address,"
	    			        + "tel=:t.tel,"
	    			        + "email=:t.email,"
	    			        + "education=:t.education,"
	    			        + "major=:t.major,"
	    			        + "school=:t.school,"
	    			        + "direction=:t.direction,"
	    			        + "subject=:t.subject,"
	    			        + "achievements=:t.achievements,"
	    			        + "infor=:t.infor,"
	    			        + "orderNo=:t.orderNo"
    						+ " WHERE id=:t.id")
    void update(@SQLParam("t") GroupPeople groupPeople);
    
    @SQL("UPDATE GroupPeople SET deleteFlag=0 WHERE id=:1 ")
    void deleteById(int id);
}